from interactive import *

#1) Test finding a mouse and editing its values
css("#ColonyView")
linkpart("EPO").click()
twait()

css("#ColonyMenu")
linkpart("Mice").click()
twait()

Select(css("#MouseList select")).select_by_value("1")
twait()

Edit()
css("#MouseDetail #Tag").clear()
css("#MouseDetail #Tag").send_keys("MOUSETEST")
css("#MouseDetail #Cage").send_keys("1234");
css("#MouseDetail #Comment").send_keys("This is a test")
twait()

Done()
twait()

Select(css("#MouseList select")).select_by_value("1")
twait()
assert(css("#MouseDetail #Tag").get_attribute("value") == "MOUSETEST")
assert(css("#MouseDetail #Cage").get_attribute("value") == "1234")
assert(css("#MouseDetail #Comment").get_attribute("value") == "This is a test")
twait()

#2) find a mouse, edit its values and choose cancel
Back()
Select(css("#MouseList select")).select_by_value("2")
twait()

Edit()
css("#MouseDetail #Tag").clear()
css("#MouseDetail #Tag").send_keys("MOUSETEST2")
css("#MouseDetail #Cage").send_keys("1234");
css("#MouseDetail #Comment").send_keys("This is a test")
twait()

Cancel()
twait()
Back()
twait()

Select(css("#MouseList select")).select_by_value("2")
twait()
assert(css("#MouseDetail #Tag").get_attribute("value") == "2")
assert(css("#MouseDetail #Cage").get_attribute("value") == "")
assert(css("#MouseDetail #Comment").get_attribute("value") == "")
twait()

driver.quit()
